﻿using System;
using System.Collections.Generic;
using TeF.Runner.Services;

namespace TeF.Runner
{
    /// <summary>Runner's API</summary>
    public interface IManager
    {
        /// <summary>Loads test assembly</summary>
        /// <param name="path">Path to assembly with tests</param>
        /// <exception cref="ArgumentException">If <see cref="path"/> is null or empty string</exception>
        /// <exception cref="TestAssemblyLoaderException">If assembly's file does not have dll extension</exception>
        /// <exception cref="TestAssemblyLoaderException">If assembly's file cannot be found</exception>
        /// <exception cref="TestFinderException">If test container has more than one container's setup methods</exception>
        /// <exception cref="TestFinderException">If test container has more than one container's teardown methods</exception>
        /// <exception cref="TestFinderException">If test container has more than one test's setup methods</exception>
        /// <exception cref="TestFinderException">If test container has more than one test's teardown methods</exception>
        ITestAssembly LoadTestAssembly(string path);

        /// <summary>Runs all listed test entities synchronously</summary>
        /// <exception cref="ArgumentNullException">If <see cref="testEntities"/> is null</exception>
        void Run(IEnumerable<ITestEntity> testEntities);

        /// <summary>Runs all listed test entities asynchronously</summary>
        /// <exception cref="ArgumentNullException">If <see cref="testEntities"/> is null</exception>
        void RunAsync(IEnumerable<ITestEntity> testEntities);

        /// <summary>Runs all tests in listed assemblies</summary>
        /// <param name="assemblyPathes">Pathes to test assemblies</param>
        /// <param name="reportDirectoryPath">Path to directory where result report should be placed </param>
        /// <returns>Path to result report file</returns>
        /// <exception cref="ArgumentNullException">If <see cref="assemblyPathes"/> is null</exception>
        /// <exception cref="ArgumentException">If <see cref="reportDirectoryPath"/> is null or empty</exception>
        /// <exception cref="ArgumentException">If <see cref="reportDirectoryPath"/> path does not exist</exception>
        /// <exception cref="TestAssemblyLoaderException">If one of the assembly's files does not have dll extension</exception>
        /// <exception cref="TestAssemblyLoaderException">If one of the assembly's file cannot be found</exception>
        /// <exception cref="TestFinderException">If in one of the assemblies test container has more than one container's setup methods</exception>
        /// <exception cref="TestFinderException">If in one of the assemblies test container has more than one container's teardown methods</exception>
        /// <exception cref="TestFinderException">If in one of the assemblies test container has more than one test's setup methods</exception>
        /// <exception cref="TestFinderException">If in one of the assemblies test container has more than one test's teardown methods</exception>
        string Run(string[] assemblyPathes, string reportDirectoryPath);
        
        /// <summary>Occurs when running is completed</summary>
        event EventHandler RunCompleted;
    }
}
